Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rs2bril #227

Merged
merged 4 commits into from
Jul 22, 2022
Merged

Rs2bril #227

merged 4 commits into from
Jul 22, 2022

Conversation

Pat-Lafon
Copy link
Contributor

@Pat-Lafon Pat-Lafon commented Jul 20, 2022

I've been motivate to write rs2bril like the current ts2bril. I didn't quite realize until half way through that the stalled #107 also has an implementation of a rs2bril like tool. We approached the problem in a similar way so there was some repeated work though we are targeting different extensions of Bril so this pr has some set of new contributions. The implementation structure is similar enough that https://www.cs.cornell.edu/courses/cs6120/2020fa/blog/bril-algebraic-data-types/ can be used as an overview.

#107's rs2bril targets core Bril + ADT's. ts2bril targets core Bril + Floats. This pr implements a rs2bril tool which targets core Bril + Floats + Memory. I've added a full list of limitations that I'm aware of to the README, I will highlight a few:

  • Currently requires all variable declarations to be explicitly typed.
  • println! is expected to be valid rust unlike in Algebraic types extension #107, however the format string is ignored during compilation and you can only pass variables as arguments.
  • It always assumes valid Rust code(you can run all of your code as Rust first!), except in the case that you want to pass arguments to main. In this case, just declare function arguments to main like any other function(which makes it not valid Rust).
  • Memory is implemented as Rust Arrays/Slices. This means that they are statically sized with integer literals and must be initialized on creation. I've also specialized drop to compile to free. Programmers need to manually manage their memory(by dropping arrays). This could be a use case for https://www.cs.cornell.edu/courses/cs6120/2020fa/blog/asmm/ .

It can provide source positions via the -p flag though many are probably off/missing.

example.rs has some example syntax that is supported. I've added a set of tests which are equivalent to the ts2bril tests plus more complicated benchmarks like ackermann.rs, riemann.rs and cholesky.rs(which is probably the best representation of what rs2bril can do).

@Pat-Lafon Pat-Lafon force-pushed the rs2bril branch 2 times, most recently from b10e5d8 to bfc0321 Compare July 20, 2022 18:23
@sampsyo
Copy link
Owner

sampsyo commented Jul 21, 2022

Wow; super cool that this works!! I really like the idea to support passing around slices as the way to get Bril pointers. It's a nice compromise between Rustiness and practicality for mapping to the Bril memory extension.

I'm sure there's plenty more to do, but do you think this is ready for "v1" to be merged into the monorepo?

@Pat-Lafon
Copy link
Contributor Author

I'm sure there's plenty more to do, but do you think this is ready for "v1" to be merged into the monorepo?

I think I've largely accomplished what I set out to do(be able to compile and run one of the non-trivial memory-based benchmarks in both the Rust Playground and as Bril). It has some kind of documentation which includes it's limitations(which can double as future work) along with a passing test suite/lint checks. I don't have any further commits planned for this pr beyond any changes you may ask for or bug fixes that come up.

@sampsyo
Copy link
Owner

sampsyo commented Jul 22, 2022

Awesome! Super great work on this; it looks extremely cool.

@sampsyo sampsyo merged commit 8383f6b into sampsyo:main Jul 22, 2022
@Pat-Lafon Pat-Lafon deleted the rs2bril branch July 22, 2022 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants